package gluck.sintactico.symbolTable;

import java.util.ArrayList;

public class Level {

	int index;
	ArrayList<Integer> levels;

	public Level() {
		levels = new ArrayList<Integer>();
		levels.add(0);
		levels.add(0);
		index=0;
	}
	
	public void LevelUp()
	{
		levels.add(0);
		index++;
		levels.set(index, levels.get(index)+1);
		
	}
	
	public void LevelDown()
	{
		
		if(index>0)
		{	
			levels.remove(index+1);
			index--;
		}
	}
	
	public void addLevel()
	{
		levels.set(index, levels.get(index)+1);
	}
	
	public void downLevel()
	{
		levels.set(index, levels.get(index)+1);
	}
	
	public int getDepth()
	{
		return index;
	}

	@Override
	public String toString() {
		StringBuffer string= new StringBuffer();
		int i;
		for(i=1;i<=index;i++)
		{
			string.append(levels.get(i));
			if(i!=index)
			{
				string.append('.');
			}
		}
		
		return string.toString();
	}
	
	
}
